/// FileName: light_menu
/// Author: admin
/// Date: 2021-05-15 20:18
/// Description: 轻菜单，用于展示标签

import 'package:flutter/material.dart';
import 'package:high_help_apps/common/values/colors.dart';
import '../little_card.dart';
import 'light_menu_introduction.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class LightMenu extends StatelessWidget {

  LightMenu({this.paddingLength, this.title, required this.ligtMenuData, this.titleColor});

  /// 菜单的内边距
  final double? paddingLength;

  /// 轻菜单的名称
  final String? title;

  /// 菜单标题颜色
  final Color? titleColor;

  /// 轻菜单内容
  final List<LightMenuIntroduction> ligtMenuData;

  @override
  Widget build(BuildContext context) {
    return Card(
      margin: EdgeInsets.fromLTRB(0, 7.0.r, 0, 7.0.r),
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadiusDirectional.circular(10.0.r)
      ),
      elevation: 0,
      child: Column(
        children: [
          buildHeader(context),
          buildContent(context)
        ],
      ),
    );
  }

  Widget buildHeader(context) {
    return Container(
      alignment: Alignment.centerLeft,
      margin: EdgeInsets.fromLTRB(30.r, 17.5.r, 0, 0),
      child: Text(
        this.title ?? '',
        style: TextStyle(
            color: titleColor ?? Theme.of(context).primaryColor,
            fontSize: 14.5.sp,
            fontWeight: FontWeight.bold
        ),
      ),
    );
  }

  Widget buildContent(context) {
    return Container(
        padding: EdgeInsets.all(this.paddingLength ?? 10.0.r),
        child: IntrinsicHeight(
            child: Wrap(
              children: this.ligtMenuData.map((item) {
                return LittleCard(
                    title: item.title,
                    onTap: item.onTap
                );
              }).toList(),
            )
        )
    );
  }
}
